chore: add dev container support for simplicity#581
chore: add dev container support for simplicity#581Tony-WLB wants to merge 2 commits intocanonical:mainfrom
Conversation
|
|
||
| WORKDIR /workspace | ||
|
|
||
| USER netplan |
There was a problem hiding this comment.
Let's try to use the default ubuntu user to avoid having to do useradd/usermod and stuff.
There was a problem hiding this comment.
The user is changed to the default ubuntu.
| python3-pytest \ | ||
| python3-pytest-cov \ | ||
| python3-yaml \ | ||
| sudo \ |
There was a problem hiding this comment.
Is this really needed? Isn't it installed by default in ubuntu?
There was a problem hiding this comment.
Yes, I double-checked that the sudo package is not included by default in the Docker Ubuntu image.
|
|
||
| ```sh | ||
| sudo apt install \ | ||
| bash-completion \ |
There was a problem hiding this comment.
As mentioned above, we can link to the Dockerfile here for the list of deps, to avoid them getting out of sync.
There was a problem hiding this comment.
Done. This part refers to the # netplan dependencies section in the Dockerfile now.
|
|
||
| # Build dependencies | ||
|
|
||
| > If you prefer using a prebuilt development environment, see the dev container image definition in [`.devcontainer/Dockerfile`](.devcontainer/Dockerfile). |
There was a problem hiding this comment.
Let's add a few commands for how you use Docker to start a container in your terminal. Something like this (completely untested):
docker build
docker run ./myfile
$ make
$ ./netplan foo # or "make run"?
There was a problem hiding this comment.
The build and run command examples have been added.
| gcovr \ | ||
| pandoc | ||
| $ docker build -t netplan-dev -f .devcontainer/Dockerfile . | ||
| $ docker run -it --rm -v $(pwd):/workspace --name netplan-dev netplan-dev bash |
There was a problem hiding this comment.
This is helpful, and works on my machine. However, I think to make this useful we have to be able to build and run netplan from within the container. But make doesn't work for me:
ubuntu@c7be5a34e560:/workspace$ make
meson compile -C _build --verbose
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /workspace/_build -v
ninja: Entering directory `/workspace/_build'
ninja: error: '/home/ben.hoyt@canonical.com/w/netplan/features_h_generator.sh', needed by 'dbus/_features.h', missing and no known rule to make it
make: *** [Makefile:8: default] Error 1
Do you know why? I'm guessing it's an error with non-relative directories (the error references /home/ben.hoyt@canonical.com/w/netplan but I think that should be /workspace inside the container).
There was a problem hiding this comment.
@benhoyt I did not run into this issue. I am running this container build from within an Ubuntu VM and is compiling fine.
As you had mentioned, it is likely due to difference in the directory referred during the build.
There was a problem hiding this comment.
Maybe it's caused by the volume not being mounted correctly, -v $(pwd):/workspace. It combines the CWD with the workspace inside the container. Could you please try running this Docker container directly inside the netplan directory?
There was a problem hiding this comment.
I did a make clean and that get rid of the first error (I guess it was leftover stuff in the _build directory from a non-Docker build). However, now I get this error with a clean container -- seems to be a permissions error creating anything inside the container:
$ docker run -it --rm -v $(pwd):/workspace --name netplan-dev netplan-dev bash
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@f41ed6926e5c:/workspace$ make
meson setup _build --prefix=/usr
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/mesonbuild/mesonmain.py", line 194, in run
return options.run_func(options)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 357, in run
app = MesonApp(options)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 68, in __init__
(self.source_dir, self.build_dir) = self.validate_dirs()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 148, in validate_dirs
(src_dir, build_dir) = self.validate_core_dirs(self.options.builddir, self.options.sourcedir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/mesonbuild/msetup.py", line 121, in validate_core_dirs
os.makedirs(ndir1, exist_ok=True)
File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/workspace/_build'
ERROR: Unhandled python OSError. This is probably not a Meson bug, but an issue with your build environment.
make: *** [Makefile:11: _build] Error 13
ubuntu@f41ed6926e5c:/workspace$ mkdir _build
mkdir: cannot create directory '_build': Permission denied
ubuntu@f41ed6926e5c:/workspace$ touch foo
touch: cannot touch 'foo': Permission denied
If you guys don't see the issue, I'll try to debug this with Jegadish tomorrow in our 1:1.
|
@Tony-WLB
|
|
Hi @JegadishD ! Yeah, I have the same concern about the VS Code part. Since editor choice is largely up to individual developers, I’m not sure how much emphasis we should put on VS Code here. The current dependencies part can cover the tests triggered by However, as you mentioned, this container is not running systemd as PID 1, and that does bring some troubles for realistic testing. It seems that some manual setups are needed to run realistic tests with |
Hi @Tony-WLB
The systemd package is not present in the ubuntu docker container. In the process list of the container, I do not see systemd or networkd running in it.
Yes, The container dev environment can be be useful to an extent and the VM can be a suitable environment to test the real changes. |
This pull request introduces a development container setup to streamline onboarding and development for the Netplan project. It also completes the dependencies list.
Dev container environment:
.devcontainer/Dockerfile- define a reproducible Ubuntu 24.04-based development environment.devcontainer/devcontainer.json- configure the dev containerDocumentation updates:
README.mdto mention the new dev container as an alternative to manual dependency installation, and revised the dependency list to match the packages installed in the dev container.